package cn.lutu.lutu.service.impl;


import cn.lutu.lutu.service.UploadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

@Service
@Slf4j
public class UploadServiceImpl implements UploadService{



    public String getDatePath(){

        SimpleDateFormat f = new SimpleDateFormat("/yyyy/MM/dd/");
        String datePath=f.format(new Date());
        return datePath;
    }

    public String getFileName(MultipartFile file) {
        String fileName = file.getOriginalFilename();
        String suffix= fileName.substring(fileName.lastIndexOf("."));
        fileName= UUID.randomUUID()+suffix;
        return fileName;
    }


}
